using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using EYDIngenieria.ERP.ObjetosDeNegocio.Dominio;

public partial class MasterPage : System.Web.UI.MasterPage
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session.Keys.Count == 0) Response.Redirect("LogIn.aspx");
        Usuario usuario = (Usuario)Session["usuario"];
        lblFecha.Text = DateTime.Now.ToString("dd/mm/yyyy");
        lbtSalir.Text = usuario.Nombre + " " + usuario.Apellidos + " (Salir)";
       
       
    }
    protected void TreeView1_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
    {
        SiteMapNode nodeFromSiteMap = (SiteMapNode)e.Node.DataItem;

        if (!nodeFromSiteMap.Roles.Contains(((Usuario)Session["usuario"]).Rol.Codigo) && nodeFromSiteMap.Roles.Count >0 && e.Node.Parent != null)
        {
            //e.Node.SelectAction = TreeNodeSelectAction.None;
            e.Node.Parent.ChildNodes.Remove(e.Node);
        }
        
    }
    protected void Salir(object sender, EventArgs e)
    {
        Session.Abandon();
        Session.RemoveAll();
        Boolean parent = false;


        string url = Request.ApplicationPath + "/Login.aspx";
        Response.Redirect(url);
       
       

    }
}
